package zzcltw.com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zzcltw.com.mapper.InvestMapper;
import zzcltw.com.mapper.InvestMeetMapper;
import zzcltw.com.object.Invest;
import zzcltw.com.object.InvestMeet;
import zzcltw.com.service.IInvestService;
import zzcltw.com.service.common.impl.BaseServiceImpl;

@Service("investService")
public class InvestServiceImpl extends BaseServiceImpl implements IInvestService{
	@Autowired
    private InvestMapper investMapper;
	@Autowired
    private InvestMeetMapper investMeepMapper;
	/**
	 * 
	 * @Title  招商介绍查询
	 * @Description:  queryInvestList
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> queryInvestList(Map<String,String> map){
		List<Map<String,String>> list = investMapper.queryInvestList(map);
		int count = investMapper.queryInvestListCount(map);
		Map<String,Object> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  招商介绍详情
	 * @Description:  queryInvestDtlById
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月22日
	 */
	public Map<String,Object> queryInvestDtlById(Map<String,String> map){
		Map<String,String> bean = investMapper.queryInvestDtlById(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", null);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  招商介绍新增
	 * @Description:  saveInvestInfo
	 * @param: @param invest
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
 */
	public Map<String,Object> saveInvestInfo(Invest invest) throws Exception{
		String investId = getSequence("t_pt_invest");		
		invest.setInvestId(investId);
		invest.setValidStsCd("1");
		int flag = investMapper.saveInvestInfo(invest);
		/*String filePaths = invest.getFilePaths();
    	String crtUserId = invest.getCrtUserId();
    	if(StringUtil.isNotEmpty(filePaths)){
    		String arr[] = filePaths.split(",");
    		for(int i=0;i<arr.length;i++){
    			Map<String,String> map = new HashMap<>();
    			String fileId = getSequence("t_pt_invest_file");	
    			map.put("fileId", fileId);
    			map.put("investId", investId);
    			map.put("fileTypeCd", "01");
    			map.put("fielNm", arr[i]);
    			map.put("filePath", arr[i]);
    			map.put("crtUserId", crtUserId);
    			map.put("validStsCd", "1");
    			investMapper.saveInvestInfoFile(map);
    		}
    	}*/
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
		 * 
		 * @Title  招商介绍修改
		 * @Description:  updateInvestInfo
		 * @param: @param invest
		 * @param: @return
		 * @return 
		 * @throws
		 * @author zzx
		 * @Date 2018年8月15日
	 */
	public Map<String,Object> updateInvestInfo(Invest invest) throws Exception{
		String investId = invest.getInvestId();		
		int flag = investMapper.updateInvestInfo(invest);
		/*String filePaths = invest.getFilePaths();
    	String crtUserId = invest.getCrtUserId();
    	Map<String,String> m = new HashMap<>();
    	m.put("investId", investId);
    	investMapper.delInvestInfoFile(m);
    	if(StringUtil.isNotEmpty(filePaths)){
    		String arr[] = filePaths.split(",");
    		for(int i=0;i<arr.length;i++){
    			Map<String,String> map = new HashMap<>();
    			String fileId = getSequence("t_pt_invest_file");	
    			map.put("fileId", fileId);
    			map.put("investId", investId);
    			map.put("fileTypeCd", "01");
    			map.put("fielNm", arr[i]);
    			map.put("filePath", arr[i]);
    			map.put("crtUserId", crtUserId);
    			map.put("validStsCd", "1");
    			investMapper.saveInvestInfoFile(map);
    		}
    	}*/
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  招商介绍删除
	 * @Description:  delInvestInfo
	 * @param: (Map<String,String>
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> delInvestInfo(Map<String,String> map) throws Exception{
		int flag = investMapper.delInvestInfo(map);
    	//investMapper.delInvestInfoFile(map);
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  招商会议介绍查询
	 * @Description:  queryInvestMeetList
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> queryInvestMeetList(Map<String,String> map){
		List<Map<String,String>> list = investMeepMapper.queryInvestMeetList(map);
		int count = investMeepMapper.queryInvestMeetListCount(map);
		Map<String,Object> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");
		return map1;
	}
	/**
	 * 
	 * @Title  招商会议介绍新增
	 * @Description:  saveInvestMeetInfo
	 * @param: @param invest
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
 */
	public Map<String,Object> saveInvestMeetInfo(InvestMeet invest) throws Exception{
		String meetId = getSequence("t_pt_invest_meet");		
		invest.setMeetId(meetId);
		invest.setValidStsCd("1");
		int flag = investMeepMapper.saveInvestMeetInfo(invest);		
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  招商会议介绍详情
	 * @Description:  queryInvestMeetDtlById
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月23日
	 */
	public Map<String,Object> queryInvestMeetDtlById(Map<String,String> map){
		Map<String,String> bean = investMeepMapper.queryInvestMeetDtlById(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", null);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
		 * 
		 * @Title  招商会议介绍修改
		 * @Description:  updateInvestMeetInfo
		 * @param: @param invest
		 * @param: @return
		 * @return 
		 * @throws
		 * @author zzx
		 * @Date 2018年8月15日
	 */
	public Map<String,Object> updateInvestMeetInfo(InvestMeet invest) throws Exception{
		int flag = investMeepMapper.updateInvestMeetInfo(invest);		
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  招商会议介绍删除
	 * @Description:  delInvestMeetInfo
	 * @param: (Map<String,String>
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> delInvestMeetInfo(Map<String,String> map) throws Exception{
		int flag = investMeepMapper.delInvestMeetInfo(map);		
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}	
}
